﻿@model IEnumerable<CmsTemplate>
           
@{
    Layout = "~/admin/Templates/TelerikAdministration.cshtml";
}

@{
    ResFile = "cms_Templates";
    ViewBag.Title = _("Page templates");
}

<h1 class="g-clear">
	<i class="b-icon b-icon_h b-icon_h_pages"></i>
	<span class="b-overflow">
		@_("Templates")
		<span class="b-intro-text">@_("The table below contains all templates used on the site.")</span> 
	</span>  
</h1>	

<div id="TabStrip" class="t-widget t-tabstrip t-header">
	<ul class="t-reset t-tabstrip-items">
		<li class="t-item t-state-default">
			<a href="/admin/cmspage" class="t-link">@_("Pages")</a>			
		</li>
		<li class="t-item t-state-active">
			<a href="/admin/cmstemplate" class="t-link">@_("Templates")</a>			
		</li>
		<li class="t-item t-state-default">
			<a href="/admin/cmspagemetafields" class="t-link">@_("Page Metas")</a>			
		</li>		
	</ul>
	<div style="display: block;" id="TabStrip-1" class="t-content t-state-active">
		<div class="t-content-inner g-clear">
			<p class="clear-left">
			    <a class="b-button b-button_save" href="@Url.Action("add", "cmstemplate")">@_("Add a template")</a>
			</p>
			@{Html.RenderPartial("ErrorPanel");}
			@(Html.Telerik().Grid(Model).Name("TemplateGrid")
			        .Columns(columns =>
			        {
			            columns.Bound(p => p.TemplateName)
                            .Title(_("Template name"))
                            .Template(@<text> <a href="@Url.Action("edit", "cmstemplate", new { id = item.Id })">@item.TemplateName</a> </text>)
                            .ClientTemplate("<a href=" + Url.Action("edit", "cmstemplate") + "/<#= Id#>><#= TemplateName#></a>");
			            columns.Bound(p => p.Id).Template(
			                @<text>                  
			                <a class="template-preview b-icon b-icon_loupe" href="@Url.Action("showregions", "cmstemplate", new { id = item.Id })">@_("Link")</a>
			                </text>
			            ).Title(_("Preview")).Width(60).HtmlAttributes(new { @class = "text-center" });
			            columns.Bound(p => p.TemplateTypeDescription).Title(_("Template type")).Width(100);
			            columns.Bound(p => p.TemplateRegionsCount).Title(_("Regions count")).Width(100);
			            columns.Bound(p => p.DateCreated).Format("{0:dd/MM/yyyy}").Width(100);
			            columns.Template(
			                @<text>
			                <a class="b-icon b-icon_delete" title="@_("Delete")" href="@Url.Action("delete", "cmstemplate", new { id = item.Id })">@_("Delete")</a>
			                </text>
			            )
                        .ClientTemplate("<a class='b-icon b-icon_delete' title='" + _("Delete") + "' href='" + Url.Action("Delete", "cmstemplate") + "/<#= Id#>" + "'>" + _("Delete") + "</a>")
			            .Title(_("Delete")).Width(75);
			        })
                    .DataBinding(dataBinding => dataBinding.Ajax().Select("_Index", "CmsTemplate"))
			        .Pageable(paging => paging.Style(GridPagerStyles.Numeric).Total(ViewBag.Total).PageSize(ViewBag.PageSize).Enabled(ViewBag.Total > ViewBag.PageSize))
			    )
			@{Html.RenderPartial("GridSizer", (int)ViewBag.PageSize);}
		</div>
	</div>
</div>